package com.hzw.jdbc.statementTest;

import com.mysql.cj.jdbc.Driver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class DeleteDemo01 {

    public static void main(String[] args) throws Exception{
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url="jdbc:mysql://localhost:3306/test";
        Connection root = DriverManager.getConnection(url, "root", "123456");
        Statement statement = root.createStatement();
        String sql="delete from user where id='8'";
        int i = statement.executeUpdate(sql);
        if (i>0){
            System.out.println("删除成功");
        }
        statement.close();
        root.close();
    }
}
